package com.droidclaimsurveyor.activity;

import com.droidclaimsurveyor.activity.MainActivity;
import com.droidclaimsurveyor.R;

import android.os.Bundle;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class MainActivity extends TabActivity {
	Resources resources;
	TabHost tabHost;
	private static String sessionId;
	private static String ownerName;
	private static int claimId;

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
			
		Initail();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		
		return true;
	}

	public static String getSessionId()
	{
		return MainActivity.sessionId;
	}
	
	public static void setSessionId(String sessionId)
	{
		MainActivity.sessionId = sessionId;
	}

	public void Initail()
	{
		resources = getResources(); 
		tabHost = (TabHost)findViewById(android.R.id.tabhost);
		
		// Android tab
		Intent intentHome = new Intent().setClass(this, HomeActivity.class);
		TabSpec tabHome = tabHost
			.newTabSpec("Home")
			.setIndicator("", resources.getDrawable(R.drawable.icon_android_config))
			.setContent(intentHome);
		
		Intent intentClaimWork = new Intent().setClass(this, ClaimWorkActivity.class);
		intentClaimWork.putExtra("request_id", "101");
		TabSpec tabClaimWork = tabHost
			.newTabSpec("Work")
			.setIndicator("", resources.getDrawable(R.drawable.icon_work_config))
			.setContent(intentClaimWork);
		
		Intent intentDetail = new Intent().setClass(this, ClaimDetailActivity.class);
		intentDetail.putExtra("request_id", "101");
		TabSpec tabDetail = tabHost
			.newTabSpec("History")
			.setIndicator("", resources.getDrawable(R.drawable.icon_detail_config))
			.setContent(intentDetail);

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        
		String surveyerId = bundle.getString("surveyerId");
		String name = bundle.getString("name");
		String surname = bundle.getString("surname");
		String mobile = bundle.getString("mobile");
		String email = bundle.getString("email");
		String imgPath = bundle.getString("imgPath");
		Boolean status = bundle.getBoolean("status");


		intentHome.putExtra("surveyerId", surveyerId);
		intentHome.putExtra("name", name);
		intentHome.putExtra("surname", surname);
		intentHome.putExtra("mobile", mobile);
		intentHome.putExtra("email", email);
		intentHome.putExtra("imgPath", imgPath);
		intentHome.putExtra("status", status);
		
        tabHost.addTab(tabHome);
        tabHost.addTab(tabClaimWork);
        tabHost.addTab(tabDetail);
	}
	
	public static String getOwnerName() {
		return ownerName;
	}

	public static void setOwnerName(String ownerName) {
		MainActivity.ownerName = ownerName;
	}
	
	public static int getClaimId(){
		return MainActivity.claimId;
	}
	
	public static void setClaimId(int claimId) {
		MainActivity.claimId = claimId;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub

		/*
		 * if(item.getId()==R.id.xxx)
		 * Logout Call Service.Logout()
		 * Remove SessionId >> SetEmpty
		 */
		return super.onOptionsItemSelected(item);
	}
}
